/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ufop.controller;

import java.sql.Date;

import com.ufop.model.ItemPauta;
import com.ufop.model.Pauta;
import com.ufop.view.PautaView;
import com.ufop.view.SistemaVotoView;
import com.ufop.view.TurnoVotacaoView;

import javax.swing.JDesktopPane;
import javax.swing.JFrame;

public class SistemaVotoController {
    protected SistemaVotoView svv;
    public static JDesktopPane desktop = new JDesktopPane();
    
    //telas - VIEWs
    private static PautaView pautaView;
    private static TurnoVotacaoView turnoView;
    
    public static void main(String[] args){
        new SistemaVotoController();       
    }

    public SistemaVotoController() {
     this.svv= new SistemaVotoView();
     this.svv.createAndShowGUI();
    }
    
    public static PautaView getPautaView(){
		if((pautaView == null)||(pautaView.isClosed())){
			//popular MODELO PAUTA
			Pauta p = new Pauta();
			PautaController pCtrl = new PautaController(p);
			pautaView = new PautaView(pCtrl, p);
			desktop.add(pautaView);
			p.carregaListPauta();
		}
		pautaView.setVisible(false);
		pautaView.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		return pautaView;
	}
    
    public static TurnoVotacaoView getTurnoView(PautaController pCtrl, ItemPauta iP){
		if(turnoView == null)
			turnoView = new TurnoVotacaoView(pCtrl, iP);
		turnoView.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
		turnoView.setVisible(true);
		return turnoView;
	}
    
}
